import React, { useEffect, useMemo, useState } from 'react';
import "./index.less";
import { Card, Col, Grid, Row, Tree, TreeProps, message } from 'antd'; // 假设你使用了Ant Design组件库  
import { getDepartTree } from '@/services/demo/UserController';

const defaultPageData = [{ treeTitle: "组织部门", tableTitle: "账号列表",method:getDepartTree }, { treeTitle: "岗位类别", tableTitle: "岗位列表" }, { treeTitle: "角色类别", tableTitle: "角色列表" }];
const BasicLayout: React.FC<{ children: React.ReactNode; type: number; }> = (props) => {
    const [treeData, setTreeData] = useState([]);
    const [pageData, setPageData] = useState({});


    useMemo(() => {
        if (props.type || props.type === 0) {
            setPageData(defaultPageData[props.type]);

        }
        // switch (props.type) {
        //     // 账号管理
        //     case 0:
        //         setPageData({ treeTitle: "组织部门", tableTitle: "账号列表" });
        //         break;

        //     default:
        //         break;
        // }
    }, [props.type]);

    useEffect(() => {
        // getDepartTree().then(res => {
        //     console.log(res);
        //     if (res.success) {
        //         setTreeData(res.result);
        //     } else {
        //         message.error("获取部门数据失败");
        //     }
        // });
    }, []);
    const onSelect: TreeProps['onSelect'] = (selectedKeys, info) => {
        console.log('selected', selectedKeys, info);
    };
    return <Row className='alyy' gutter={[20, 0]}>
        <Col span={6}>
            <Card>
                <Tree
                    defaultExpandedKeys={['0-0-0']}
                    onSelect={onSelect}
                    fieldNames={{ title: "title", key: "id", children: "children" }}
                    treeData={treeData}
                />
            </Card>
        </Col>
        <Col span={18}>
            <Card>右侧</Card>
        </Col>
    </Row>;
};


export default BasicLayout;